package com.hrms.controller;

import com.hrms.domain.Employee;
import com.hrms.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;



@RestController
@RequestMapping("/admin/employee")
public class EmployeeController{
    @Autowired
    private EmployeeService employeeService;

    //查询员工管理列表
    @GetMapping("/list")
    public List<Employee> selectInfos() {
        return employeeService.selectInfos();
    }

    //获取员工管理详细信息
    @GetMapping(value = "/{empNo}")
    public Employee getInfo(@PathVariable("empNo") Long empNo){
        return employeeService.getInfo(empNo);
    }

    //新增员工管理
    @PostMapping
    public Map add(@RequestBody Employee employee){
        employee.setCreateTime(new Date());
        employee.setModifyTime(new Date());
        return employeeService.add(employee);
    }

    //修改员工管理
    @PutMapping
    public Map edit( @RequestBody Employee employee){
        return employeeService.updateEmployee(employee);
    }


    //批量删除员工管理
    @DeleteMapping("/{empNos}")
    public Map remove(@PathVariable Long[] empNos){
        return employeeService.deleteEmployeeByEmpNos(empNos);
    }
}
